﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinApp.i18n;

namespace WinApp.View
{
    public partial class MyDownloads : UIPage
    {
        public DownloadList _fDownloading;

        public DownloadList _fDownloaded;
        public MyDownloads()
        {
            InitializeComponent();
            this.Text = Language.GetLang("MyDownloads");

            tabPage1.Text = Language.GetLang("page_Downloaded");
            if (_fDownloading == null)
                _fDownloading = new DownloadList();
            _fDownloading.Dock = DockStyle.Fill;
            tabPage1.Controls.Add(_fDownloading);

            tabPage2.Text = Language.GetLang("page_Downloading");
            if (_fDownloaded == null)
                _fDownloaded = new DownloadList();
            _fDownloaded.Dock = DockStyle.Fill;
            tabPage2.Controls.Add(_fDownloaded);

        }

        private void uiTabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var tabControl = sender as TabControl;
            var currentPage = tabControl.SelectedTab;

            switch (tabControl.SelectedIndex)
            {
                case 0:
                    btnPauseAll.Visible = true;
                    btnDown.Visible = true;

                    break;
                case 1:
                    btnPauseAll.Visible = false;
                    btnDown.Visible = false;

                    break;
                default:
                    break;
            }
        }

        private async void btnDown_ClickAsync(object sender, EventArgs e)
        {
            await _fDownloading.DownloadAllAsync();



            //_fDownloading.ResetData();
            //_fDownloading.Refresh();
        }
    }
}
